Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Only obtain a bearer token once at a time #1968

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented May 29, 2023

Currently, on pushes, we can start several concurrent layer pushes; each one will check for a bearer token in tokenCache, find none, and ask the server for one, and then write it into the cache.

So, we can hammer the server with 6 basically-concurrent token requests. That's unnecessary, slower than just asking once, and potentially might impact rate limiting heuristics.

Instead, serialize writes to a bearerToken so that we only have one request in flight at a time.

This does not apply to pulls, where the first request is for a manifest, which obtains a token, so subsequent concurrent layer pulls will not request a token again.

WIP: Clean up the debugging log entries.

docker/docker_client.go Outdated Show resolved Hide resolved
docker/docker_client.go Outdated Show resolved Hide resolved
@mtrmac mtrmac force-pushed the shared-token branch 4 times, most recently from 84d61b4 to e2c713b Compare June 1, 2023 17:50
@mtrmac mtrmac added the kind/feature A request for, or a PR adding, new functionality label Jun 30, 2023
@mtrmac mtrmac force-pushed the shared-token branch 2 times, most recently from 1fd9f89 to 3ec2136 Compare May 30, 2024 19:32
@mtrmac mtrmac force-pushed the shared-token branch 2 times, most recently from cd3b8ee to 8636ccc Compare July 9, 2024 20:16
@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 9, 2024

The not-directly-related refactoring are now filed separately in #2480.

mtrmac added 6 commits July 11, 2024 20:02
... because we will make it more complex.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
... to decrease indentation and remove a variable.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
We will want to manage concurrency in more detail.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
We will want to add a lock to it, so we must stop copying it by value.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
Instead of having getBearerToken* construct a new bearerToken
object, have the caller provide one.

This will allow us to record that a token is being obtained,
so that others can wait for it.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
Currently, on pushes, we can start several concurrent layer pushes;
each one will check for a bearer token in tokenCache, find none,
and ask the server for one, and then write it into the cache.

So, we can hammer the server with 6 basically-concurrent token requests.
That's unnecessary, slower than just asking once, and potentially might
impact rate limiting heuristics.

Instead, serialize writes to a bearerToken so that we only have one request in
flight at a time.

This does not apply to pulls, where the first request is for a manifest;
that obtains a token, so subsequent concurrent layer pulls will not request
a token again.

WIP: Clean up the debugging log entries.

Signed-off-by: Miloslav Trmač <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for, or a PR adding, new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant